package ee.ttu.agent.smartHouse.agent;

import ee.ttu.agent.smartHouse.services.CustomLoggingBehaviour;
import ee.ttu.agent.smartHouse.util.Constants;
import jade.core.Agent;
import jade.domain.DFService;
import jade.domain.FIPAException;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;

public class CustomLoggingAgent extends Agent {

	private static final long serialVersionUID = 5514436662839018554L;

	protected void setup() {
		// Register the gate keeper service in the yellow pages
		DFAgentDescription dfd = new DFAgentDescription();
		dfd.setName(getAID());
		ServiceDescription sd = new ServiceDescription();

		sd.setType(Constants.CUSTOM_LOGGING_SERVICE);
		sd.setName("GateKeeperLoggingService");
		dfd.addServices(sd);

		try {
			DFService.register(this, dfd);
		} catch (FIPAException fe) {
			fe.printStackTrace();
		}
		
		addBehaviour(new CustomLoggingBehaviour());
	}

	protected void takeDown() {
		// Deregister from the yellow pages
		try {
			DFService.deregister(this);
		} catch (FIPAException fe) {
			fe.printStackTrace();
		}

	}
}